#!/usr/bin/env bash


start(){
./zk1/zookeeper-3.4.8/bin/zkServer.sh start &&
./zk2/zookeeper-3.4.8/bin/zkServer.sh start &&
./zk3/zookeeper-3.4.8/bin/zkServer.sh start
}

stop(){
./zk1/zookeeper-3.4.8/bin/zkServer.sh stop &&
./zk2/zookeeper-3.4.8/bin/zkServer.sh stop &&
./zk3/zookeeper-3.4.8/bin/zkServer.sh stop
}


restart(){
echo "stop zookeeper ================"
./zk1/zookeeper-3.4.8/bin/zkServer.sh stop &&
./zk2/zookeeper-3.4.8/bin/zkServer.sh stop &&
./zk3/zookeeper-3.4.8/bin/zkServer.sh stop &&

echo "restart zookeeper================"
./zk1/zookeeper-3.4.8/bin/zkServer.sh start &&
./zk2/zookeeper-3.4.8/bin/zkServer.sh start &&
./zk3/zookeeper-3.4.8/bin/zkServer.sh start
}

test_(){
./zk1/zookeeper-3.4.8/bin/zkCli.sh -server 127.0.0.1:4181
}
case $1 in
         start)
                start
        ;;
         stop)
        	stop
        ;;
         restart)
        	restart
        	;;
        	test_)
        	test_
        	;;
        	*)
        	echo "Usage: $SCRIPTNAME {start|stop|restart|list|gc}" >&2
        exit 1
        ;;
esac
exit 0